package com.singletonapps.evory.entities;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Version;

import com.singletonapps.evory.dto.CourseVideoDto;

@Entity
@Table(name = "COURSE_VIDEO")
public class CourseVideo implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -2320677456199849927L;

	@Id
	@SequenceGenerator(name="video_seq", sequenceName="SEQ_COURSE_VIDEO_ID", allocationSize=1)
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "video_seq")
	private Long id;
	
	@ManyToOne
	@JoinColumn(name = "COURSE_ID")
	private Course cursoVideo;
	
	@Column(name = "VIDEO_NAME")
	private String nombre;
	
	@Column(name = "VIDEO_DESC")
	private String descripcion;
	
	@Column(name = "VIDEO_PATH")
	private String videoPath;
	
	@Column(name = "DATE_CREATE", nullable = false)
	private Date dateCreated;
	
	@Column(name = "DATE_UPDATE")
	private Date dateUpdated;
	
	@Version
	private int version;
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Course getCursoVideo() {
		return cursoVideo;
	}

	public void setCursoVideo(Course cursoVideo) {
		this.cursoVideo = cursoVideo;
	}

	public String getNombre() {
		return nombre;
	}

	public void setNombre(String nombre) {
		this.nombre = nombre;
	}

	public String getDescripcion() {
		return descripcion;
	}

	public void setDescripcion(String descripcion) {
		this.descripcion = descripcion;
	}

	public String getVideoPath() {
		return videoPath;
	}

	public void setVideoPath(String videoPath) {
		this.videoPath = videoPath;
	}

	public Date getDateCreated() {
		return dateCreated;
	}

	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}

	public Date getDateUpdated() {
		return dateUpdated;
	}

	public void setDateUpdated(Date dateUpdated) {
		this.dateUpdated = dateUpdated;
	}

	public int getVersion() {
		return version;
	}

	public void setVersion(int version) {
		this.version = version;
	}
	
	public CourseVideoDto toDto(){
		CourseVideoDto dto = new CourseVideoDto();
		dto.setId(this.id);
		//dto.setCursoVideo(this.cursoVideo.toDto());
		dto.setNombre(this.nombre);
		dto.setDescripcion(this.descripcion);
		dto.setVideoPath(this.videoPath);
		dto.setDateCreated(this.dateCreated);
		dto.setDateUpdated(this.dateUpdated);
		dto.setVersion(this.version);
		
		return dto;
	}
	
}
